package Demo_0506;

/**
 * @author:zhengyilong
 * @email:1797344574@qq.com
 * @phone:13479394730
 * @desc:
 * @DateTime:2022/5/6 10:53
 **/
public class Demo2 {
    public static void main(String[] args) {
        System.out.println(max(875,124));
        System.out.println(max1(505,5));
    }
    public static int max(int a,int b){
        while (true){
            if (a>b){
                a = a%b;
            }else {
                b = b%a;
            }
            if (a == 0){
                return b;
            }
            if (b==0){
                return a;
            }
        }
    }
    public static int max1(int a,int b){
        if (a==0){
            return b;
        }
        if (b==0){
            return a;
        }
        if (a>b){
            return max1(a%b,b);
        }
        if (a<b){
            return max1(a,b%a);
        }
        return 0;
    }
}

